local skel = fk.CreateSkill{
  name = "knu_julian",
}

Fk:loadTranslationTable{
  ["knu_julian"] = "聚敛",
  [":knu_julian"] = "每轮开始时，你令所有角色同时拼点：你和赢的角色获得任意张拼点牌，横置且下次受到的伤害+1。",

  ["#knu_julian"] = "聚敛：你可以获得获得任意张拼点牌",
  ["@@knu_julian"] = "聚敛",

  ["$knu_julian1"] = "朕聚天下之财，岂不为天下之事乎？",
  ["$knu_julian2"] = "府仓国库，皆归朕有！",

}

local U = require "packages/utility/utility"

skel:addEffect(fk.RoundStart, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name)
  end,
  on_cost = function (self, event, target, player, data)
    return true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    --获得角色并拼点
    local targets = table.filter(room.alive_players, function (p)
      return not p:isKongcheng()
    end)
    room:doIndicate(player, targets)
    local src = targets[1]
    table.remove(targets, 1)
    local pindian = U.startZhuLu(src, targets, skel.name)
    --获得拼点牌
    local list = {}
    table.insert(list,pindian.fromCard:getEffectiveId())
    for _, p in ipairs(pindian.tos) do
      local c = pindian.results[p].toCard:getEffectiveId()
      table.insertIfNeed(list,c)
    end
    --获得你和赢家
    local AA = {player}
    if pindian.winner then
      table.insertIfNeed(AA,pindian.winner)
    end
    for _, p in ipairs(AA) do
      if #list > 0 then
        local cards = room:askToCards(p, {
          min_num = 1,
          max_num = 99,
          include_equip = false,
          skill_name = skel.name,
          pattern = tostring(Exppattern{ id = list }),
          cancelable = true,
          expand_pile = list,
          prompt = "#knu_julian",
        })
        if #cards > 0 then
          room:moveCardTo(cards, Player.Hand, p, fk.ReasonJustMove, skel.name)
          table.forEach(cards,function (element, index, array)
            table.removeOne(list,element)
          end)
        end
      end
      p:setChainState(true)
      room:setPlayerMark(p,"@@knu_julian",1)
    end
  end,
})

skel:addEffect(fk.DamageInflicted, {
  is_delay_effect = true,
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("@@knu_julian") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    data:changeDamage(1)
    player.room:setPlayerMark(player,"@@knu_julian",0)
  end,
})

return skel